<template>
    <div class="top">
        <headIndex :hindex="num" />
        <div class="main_ny mt20">
            <div class="article" v-if="isTabel">
                <el-table :data="tableData" border style="width: 100%">
                    <el-table-column label="排名" align="center">
                        <template slot-scope="scope">
                            <span>{{ scope.$index + 1 }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="tougaoren" label="单位" align="center"></el-table-column>
                    <el-table-column prop="count" label="发稿量" align="center"></el-table-column>
                </el-table>
            </div>
            <div class="article" v-else>
                <div class="bt"><span>当前位置</span>
                    <span>></span>
                    <!-- <span><a :href="'/list?id=' + catID">{{ art_obj.categoryname }}</a></span> -->
                    <span>{{ art_obj.categoryname }}</span>
                </div>
                <h1>{{ art_obj.infotitle }}</h1>
                <div class="auth">来源：{{ art_obj.author }}<span style="padding-left:20px;">发布时间：</span>{{ art_obj.addtime }}</div>
                <div class="cont" v-html="art_obj.infocontent">
                </div>
            </div>
            
        </div>    
        <footIndex />
    </div>
</template>  
<script setup name="article">
import headIndex from './components/headIndex/index.vue'
import footIndex from './components/footIndex/index.vue'
import { oneInfo, statisticsNum } from "@/api/yxzx/info"; 
export default {
    components: {
        headIndex,
        footIndex
    },
    data() {
      return {
        art_obj: {},
        catID: '',
        tableData: [],
        isTabel: false,
        num: null,
      }
    },
    created() {
        this.getArt()
    },
    methods: {
        getArt() {
            if(this.GetQueryString('id')){
                oneInfo(this.GetQueryString('id')).then((response) => {
                    this.art_obj = response
                    this.catID = response.categoryid
                    console.log(response)
                })
            } else {
                this.num = 9
                this.isTabel = true
                statisticsNum().then((res) => {
                    this.tableData = res.data
                })

            }
            
        },
        
        // 获取地址栏的参数
        GetQueryString (name) {
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
            var r = window.location.search.substr(1).match(reg)
            if (r != null) {
            return decodeURI(r[2])
            } else {
            return null
            }
        },
    }  
}
</script>
<style>
.main_ny .article .cont a img{
   width: 16px;
   height: 16px; 
}
</style>   